package com.zde.moriserver.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import lombok.Data;
import org.dromara.autotable.annotation.ColumnComment;
import org.dromara.autotable.annotation.mysql.MysqlTypeConstant;
import org.dromara.mpe.autotable.annotation.ColumnId;
import org.dromara.mpe.autotable.annotation.Table;
import org.dromara.mpe.bind.metadata.annotation.BindField;
import org.dromara.mpe.bind.metadata.annotation.JoinCondition;
import org.dromara.mpe.processer.annotation.AutoDefine;
import org.dromara.mpe.processer.annotation.AutoMapper;
import org.dromara.mpe.processer.annotation.AutoRepository;

@AutoDefine // 新增
@AutoMapper // 新增
@AutoRepository // 新增
// @Data自动生成set get方法
@Data
@Table(value = "zde_friend", comment = "好友表")
public class FriendEntity {
    @ColumnComment("id")
    @ColumnId(mode = IdType.AUTO, comment = "id主键", type = MysqlTypeConstant.BIGINT, length = 32)
    private String id;

    @ColumnComment("用户id")
    private String userId;

    @ColumnComment("好友id")
    private String friendId;

    //状态 1是待通过 2是通过
    @ColumnComment("状态")
    private Integer status;

    //usersEntity id 和 userId 对应上
    @BindField(
            entity = UsersEntity.class, // 指定绑定的实体类
            field = "id",               // 指定 UsersEntity 中的关键字段
            conditions = @JoinCondition(
                    selfField = "userId",   // FriendEntity 中的关联字段
                    joinField = "id"        // UsersEntity 中的关联字段
            )
    )
    private UsersEntity usersEntity;
}
